package com.sunmouse.toollib.utils.system;

import android.app.Activity;

import com.sunmouse.toollib.R;

/**
 * Created by Kvin on 2017/6/5.
 */
public class AnimUtils {


    /**
     * set anim
     *
     * @param from
     * @param animStyle
     */
    public static void setAnim(Activity from, AnimStyle animStyle) {
        switch (animStyle) {
            case LEFT_IN_FADE_OUT:
                from.overridePendingTransition(R.anim.push_left_in, R.anim.fade_out);
                break;
            case RIGHT_IN_FADE_OUT:
                from.overridePendingTransition(R.anim.push_right_in, R.anim.fade_out);
                break;
            case LEFT_OUT_FADE_IN:
                from.overridePendingTransition(R.anim.push_left_out, R.anim.fade_in);
                break;
            case FADE_IN_LEFT_OUT:
                from.overridePendingTransition(R.anim.fade_in, R.anim.push_left_out);
                break;
            case RIGHT_IN_LEFT_OUT:
                from.overridePendingTransition(R.anim.push_right_in, R.anim.push_left_out);
                break;
            case LEFT_IN_RIGHT_OUT:
                from.overridePendingTransition(R.anim.push_left_in, R.anim.push_right_out);
                break;
            case DEFAULT_JUMP:
                from.overridePendingTransition(R.anim.push_right_in, R.anim.fade_out);
                break;
            case DEFAULT_BACK:
                from.overridePendingTransition(R.anim.push_half_left_in, R.anim.push_right_out);
                break;
            case TOP_IN:
                from.overridePendingTransition(R.anim.push_top_in, 0);
                break;
            case BOTTOM_IN:
                from.overridePendingTransition(R.anim.push_bottom_in, 0);
                break;
        }
    }

    /**
     * return default anim
     */
    public static AnimStyle getDefaultJumpAnim() {
        return AnimStyle.DEFAULT_JUMP;
    }

    /**
     * return default anim
     */
    public static AnimStyle getDefaultBackAnim() {
        return AnimStyle.DEFAULT_BACK;
    }


    /**
     * anim style
     **/
    public enum AnimStyle {
        LEFT_IN_FADE_OUT(1),
        RIGHT_IN_FADE_OUT(2),
        LEFT_OUT_FADE_IN(3),
        FADE_IN_LEFT_OUT(4),
        RIGHT_IN_LEFT_OUT(5),
        LEFT_IN_RIGHT_OUT(6),
        DEFAULT_JUMP(7),
        DEFAULT_BACK(8),
        TOP_IN(11),
        BOTTOM_IN(12);

        int value;

        AnimStyle(int value) {
            this.value = value;
        }
    }
}
